Bug 455268 - Add gtk-enable-tooltips GtkSetting
authorKristian Rietveld <kris@imendio.com>
Wed, 2 Jul 2008 09:32:14 +0000 (09:32 +0000)
committerKristian Rietveld <kristian@src.gnome.org>
Wed, 2 Jul 2008 09:32:14 +0000 (09:32 +0000)
2008-07-02  Kristian Rietveld  <kris@imendio.com>

Bug 455268 - Add gtk-enable-tooltips GtkSetting

* gtk/gtk.symbols:
* gtk/gtktoolbar.[ch] (gtk_toolbar_[gs]et_tooltips): deprecated.

* gtk/gtksettings.c: introduce gtk-enable-tooltips XSetting.

* gtk/gtktooltip.c (_gtk_tooltip_handle_event): take the newly
introduced XSetting into account.

* demos/gtk-demo/appwindow.c: don't use the now deprecated
gtk_toolbar_set_tooltips().

svn path=/trunk/; revision=20730

ChangeLog
demos/gtk-demo/appwindow.c
gtk/gtk.symbols
gtk/gtksettings.c
gtk/gtktoolbar.c
gtk/gtktoolbar.h
gtk/gtktooltip.c

index 2f84d4856a8541a9bb5c0bd71d47ab41fe2332f3..aeec40ccd12c1bbaf8e9cf0722e32f3206a9fdc1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-07-02  Kristian Rietveld  <kris@imendio.com>
+
+       Bug 455268 - Add gtk-enable-tooltips GtkSetting
+
+       * gtk/gtk.symbols:
+       * gtk/gtktoolbar.[ch] (gtk_toolbar_[gs]et_tooltips): deprecated.
+
+       * gtk/gtksettings.c: introduce gtk-enable-tooltips XSetting.
+
+       * gtk/gtktooltip.c (_gtk_tooltip_handle_event): take the newly
+       introduced XSetting into account.
+
+       * demos/gtk-demo/appwindow.c: don't use the now deprecated
+       gtk_toolbar_set_tooltips().
+
 2008-07-02  Cody Russell  <bratsche@gnome.org>
 
        Bug 541162 – [Win32] Update for the new GdkWindowImpl stuff
index fd3e8fb7185cf13291e97a37bfee5fae95672a8e..ee819f757b07f2ea5b137cc0db923203e385e25b 100644 (file)
@@ -509,7 +509,6 @@ do_appwindow (GtkWidget *do_widget)
                         0,                         0);
 
       bar = gtk_ui_manager_get_widget (merge, "/ToolBar");
-      gtk_toolbar_set_tooltips (GTK_TOOLBAR (bar), TRUE);
       gtk_widget_show (bar);
       gtk_table_attach (GTK_TABLE (table),
                        bar, 
index 431274e1544b2e40b31ca16f3bd018cde0091afc..c3d1071524f2de16dbe0182d868a183e40de8ed9 100644 (file)
@@ -4028,7 +4028,9 @@ gtk_toolbar_get_orientation
 gtk_toolbar_get_relief_style
 gtk_toolbar_get_show_arrow
 gtk_toolbar_get_style
+#ifndef GTK_DISABLE_DEPRECATED
 gtk_toolbar_get_tooltips
+#endif
 gtk_toolbar_get_type G_GNUC_CONST
 gtk_toolbar_insert
 gtk_toolbar_new
@@ -4036,7 +4038,9 @@ gtk_toolbar_set_drop_highlight_item
 gtk_toolbar_set_orientation
 gtk_toolbar_set_show_arrow
 gtk_toolbar_set_style
+#ifndef GTK_DISABLE_DEPRECATED
 gtk_toolbar_set_tooltips
+#endif
 gtk_toolbar_unset_style
 #endif
 #endif
index 75a3c503a7d32681a0300bb5247d199a1f84dde4..7652cacfd2da96bdb14cc227e77f9b4299d5776b 100644 (file)
@@ -115,7 +115,8 @@ enum {
   PROP_FONTCONFIG_TIMESTAMP,
   PROP_SOUND_THEME_NAME,
   PROP_ENABLE_INPUT_FEEDBACK_SOUNDS,
-  PROP_ENABLE_EVENT_SOUNDS
+  PROP_ENABLE_EVENT_SOUNDS,
+  PROP_ENABLE_TOOLTIPS
 };
 
 
@@ -859,7 +860,7 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                             NULL);
   
   g_assert (result == PROP_FONTCONFIG_TIMESTAMP);
-  
+
   /**
    * GtkSettings:gtk-sound-theme-name:
    *
@@ -925,6 +926,22 @@ gtk_settings_class_init (GtkSettingsClass *class)
                                                                   GTK_PARAM_READWRITE),
                                              NULL);
   g_assert (result == PROP_ENABLE_EVENT_SOUNDS);
+
+  /**
+   * GtkSettings:gtk-enable-tooltips:
+   *
+   * Whether tooltips should be shown on widgets.
+   *
+   * Since: 2.14
+   */
+  result = settings_install_property_parser (class,
+                                             g_param_spec_boolean ("gtk-enable-tooltips",
+                                                                   P_("Enable Tooltips"),
+                                                                   P_("Whether tooltips should be shown on widgets"),
+                                                                   TRUE,
+                                                                   GTK_PARAM_READWRITE),
+                                             NULL);
+  g_assert (result == PROP_ENABLE_TOOLTIPS);
 }
 
 static void
index 8d126482a5e39af027cf9b81472a7b115b75329e..c7b17e4d1fe9f728e857be7614397c44aa282fc2 100644 (file)
@@ -2933,6 +2933,9 @@ gtk_toolbar_unset_style (GtkToolbar *toolbar)
  * @enable: set to %FALSE to disable the tooltips, or %TRUE to enable them.
  * 
  * Sets if the tooltips of a toolbar should be active or not.
+ *
+ * Deprecated: 2.14: The toolkit-wide #GtkSettings:gtk-enable-tooltips property
+ * is now used instead.
  **/
 void
 gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
@@ -2956,6 +2959,9 @@ gtk_toolbar_set_tooltips (GtkToolbar *toolbar,
  * gtk_toolbar_set_tooltips().
  *
  * Return value: %TRUE if tooltips are enabled
+ *
+ * Deprecated: 2.14: The toolkit-wide #GtkSettings:gtk-enable-tooltips property
+ * is now used instead.
  **/
 gboolean
 gtk_toolbar_get_tooltips (GtkToolbar *toolbar)
index 818969756f7fe83771a8e1642343069d2bb15fc3..bbc5744cc546b49eb2fda27762219a6fad92670a 100644 (file)
@@ -155,9 +155,11 @@ void            gtk_toolbar_set_show_arrow          (GtkToolbar      *toolbar,
 GtkOrientation  gtk_toolbar_get_orientation         (GtkToolbar      *toolbar);
 void            gtk_toolbar_set_orientation         (GtkToolbar      *toolbar,
                                                     GtkOrientation   orientation);
+#ifndef GTK_DISABLE_DEPRECATED
 gboolean        gtk_toolbar_get_tooltips            (GtkToolbar      *toolbar);
 void            gtk_toolbar_set_tooltips            (GtkToolbar      *toolbar,
                                                     gboolean         enable);
+#endif /* GTK_DISABLE_DEPRECATED */
 GtkToolbarStyle gtk_toolbar_get_style               (GtkToolbar      *toolbar);
 void            gtk_toolbar_set_style               (GtkToolbar      *toolbar,
                                                     GtkToolbarStyle  style);
index 5b55b1adebe6e8fec7e84c9086ab1db8e9a4938c..4e12c2948b44309070b6c40d4db739f2b8805175 100644 (file)
@@ -1201,24 +1201,35 @@ _gtk_tooltip_hide (GtkWidget *widget)
     gtk_tooltip_hide_tooltip (tooltip);
 }
 
+static gboolean
+tooltips_enabled (GdkWindow *window)
+{
+  gboolean enabled;
+  gboolean touchscreen;
+  GdkScreen *screen;
+  GtkSettings *settings;
+
+  screen = gdk_drawable_get_screen (window);
+  settings = gtk_settings_get_for_screen (screen);
+
+  g_object_get (settings,
+               "gtk-touchscreen-mode", &touchscreen,
+               "gtk-enable-tooltips", &enabled,
+               NULL);
+
+  return (!touchscreen && enabled);
+}
+
 void
 _gtk_tooltip_handle_event (GdkEvent *event)
 {
   gint x, y;
   gboolean return_value = FALSE;
-  gboolean touchscreen;
   GtkWidget *has_tooltip_widget = NULL;
-  GdkScreen *screen;
   GdkDisplay *display;
   GtkTooltip *current_tooltip;
-  GtkSettings *settings;
-
-  /* Disable tooltips in touchscreen mode */
-  screen = gdk_drawable_get_screen (event->any.window);
-  settings = gtk_settings_get_for_screen (screen);
-  g_object_get (settings, "gtk-touchscreen-mode", &touchscreen, NULL);
 
-  if (touchscreen)
+  if (!tooltips_enabled (event->any.window))
     return;
 
   /* Returns coordinates relative to has_tooltip_widget's allocation. */